﻿@{
    ViewBag.Title = "客户信息";
    var customer = ViewBag.Customer as CubicFWNet.Data.Models.Customer;
    Layout = "~/Views/Shared/_InfoPage.cshtml";
}

<section class="content">
    <form class="form-horizontal" method="post" id="formMain">
        <div class="box box-solid">
            <div class="box-body">
                <div class="row">
                    <input type="hidden" name="CustomerID" value="@customer.Id" />
                    <input type="hidden" id="modalData" value="@customer.Principal">

                    <div class="form-group col-md-6 col-sm-12">
                        <label for="Name" class="col-sm-3 control-label">客户名称</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" id="Name" name="Name" value="@customer.Name">
                        </div>
                    </div>

                    <div class="form-group col-md-6 col-sm-12">
                        <label for="ShortName" class="col-sm-3 control-label">客户简称</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" id="ShortName" name="ShortName" value="@customer.ShortName">
                        </div>
                    </div>

                    <div class="form-group col-md-6 col-sm-12">
                        <label for="Saler" class="col-sm-3 control-label">我方销售员</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" value="@customer.UserName">
                        </div>
                    </div>

                    <div class="form-group col-md-6 col-sm-12">
                        <label for="Address" class="col-sm-3 control-label">客户地址</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" id="Address" name="Address" value="@customer.Address" />
                        </div>
                    </div>

                    <div class="form-group col-md-6 col-sm-12">
                        <label for="Corporation" class="col-sm-3 control-label">法人</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" id="Corporation" name="Corporation" value="@customer.Corporation" />
                        </div>
                    </div>

                    <!--json数据-->
                    <div id="json-content"></div>

                    <div class="form-group col-md-6 col-sm-12">
                        <label for="Products" class="col-sm-3 control-label">主导产品</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" id="Products" name="Products" value="@customer.Product" />
                        </div>
                    </div>

                    <div class="form-group col-md-6 col-sm-12">
                        <label for="Yield" class="col-sm-3 control-label">产量</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" id="Yield" name="Yield" value="@customer.Yield" />
                        </div>
                    </div>

                    <div class="form-group col-md-6 col-sm-12">
                        <label for="Range" class="col-sm-3 control-label">应用范围</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" id="Range" name="Range" value="@customer.Range" />
                        </div>
                    </div>

                    <div class="form-group col-md-6 col-sm-12">
                        <label for="AccountPeriod" class="col-sm-3 control-label">账期</label>
                        <div class="col-sm-9">
                            <textarea rows="3" class="form-control" id="AccountPeriod" name="AccountPeriod" readonly>@customer.AccountPeriod</textarea>
                        </div>
                    </div>

                    <div class="form-group col-md-6 col-sm-12">
                        <label for="BillingFlow" class="col-sm-3 control-label">开票对账流程</label>
                        <div class="col-sm-9">
                            <textarea rows="3" class="form-control" id="BillingFlow" name="BillingFlow" readonly>@customer.BillingFlow</textarea>
                        </div>
                    </div>

                    <div class="form-group col-md-6 col-sm-12">
                        <label for="StatementDate" class="col-sm-3 control-label">收货地址</label>
                        <div class="col-sm-9">
                            <textarea rows="3" class="form-control" id="StatementDate" name="StatementDate"  readonly>@customer.StatementDate</textarea>
                        </div>
                    </div>

                    <div class="form-group col-md-6 col-sm-12">
                        <label for="StatementCount" class="col-sm-3 control-label">发票邮寄地址</label>
                        <div class="col-sm-9">
                            <textarea rows="3" class="form-control" id="StatementCount" name="StatementCount" readonly>@customer.StatementCount</textarea>
                        </div>
                    </div>
                </div>

                <div class="row" style="display:none">
                    <div class="form-group col-md-6 col-sm-12">
                        <label class="col-sm-3 control-label">状态</label>
                        <div class="col-sm-9">
                            <span class="form-control" style="border:none">
                                @if (customer.Status == 1)
                                {
                                    <span class="btn-xs bg-green">正常</span>
                                }
                                else
                                {
                                    <span class="btn-xs bg-black">禁用</span>
                                }
                            </span>
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="form-group col-md-6 col-sm-12">
                        <label for="Memo" class="col-sm-3 control-label">备注</label>
                        <div class="col-sm-9">
                            <textarea rows="3" class="form-control" id="Memo" name="Memo" readonly>@customer.Memo</textarea>
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="form-group col-md-6 col-sm-12">
                        <label for="Creator" class="col-sm-3 control-label">创建人</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" id="Creator" name="Tolerance" value="@customer.UserName" readonly="readonly" />
                        </div>
                    </div>
                    <div class="form-group col-md-6 col-sm-12">
                        <label for="CreateTime" class="col-sm-3 control-label">创建时间</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" id="CreateTime" value="@DateTime.Now.ToString("yyyy-MM-dd HH:mm")" readonly="readonly" />
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
</section>

@section Scripts {
    <script>

        $(document).ready(function () {
            //解析Data数据
            var data = JSON.parse(document.getElementById("modalData").value);
            var $content = $('#json-content');
            var html = "";
            data.forEach(function (e, i) {
                if (typeof e.value == "undefined") {
                    e.value = "";
                }
                if (typeof e.name == "undefined") {
                    e.name = "";
                }
                if (typeof e.des == "undefined") {
                    e.des = "未知";
                }
                html += "<div class='form-group col-md-6'>";
                html += "<label for='j_a' class='col-sm-3 control-label'>" + e.des + "</label>";
                html += "<div class='col-sm-9'>";
                html += "<input type='text' class='form-control' data-des='" + e.des + "' id='" + e.name + "' name='" + e.name + "' value='" + e.value + "'  readonly>";
                html += "</div></div>";
            });
            $content.append(html);
        })

        //禁用input
        $("input").prop("readonly", "readonly");

    </script>
}